<template>
  <view v-if="detail" class="container">
    <!-- 视频 -->
    <view class="header">
      <view class="video">
        <video 
          id="myVideo" 
          class="video" 
          :src="detail.video_url"
          :controls="true" 
          :enable-progress-gesture="true" 
          :poster="detail.back_image">
        </video>
      </view>
      <view class="title">
        <view>{{detail.title||'--'}}</view>
      </view>
    </view>
    <!-- 题目列表 -->
    <view class="content">
      <view class="item" v-for="(item,index) in detail.wenti">
				<view class="dati-title">{{index + 1}}、<text class="typename" :style="item.type==2?'background:#009688':''">{{item.typename}}</text>{{item.content}}</view>
				<view class="optionbox">
          <template  v-for="(item2,index2) in item.xuanxiang">
            <view v-if="item2" class="option-li" :style="xuanzhong(item, index2)?'background: #eff1ff;border-color:#ccd3fd':''">
              <view :class="xuanzhong(item, index2)?'xx-xuhao duoxuan xuanzhong':'xx-xuhao duoxuan'" v-if="item.type==2">{{xuhao(index2)}}</view>
              <view :class="xuanzhong(item, index2)?'xx-xuhao xuanzhong':'xx-xuhao'" v-else>{{xuhao(index2)}}</view>
              <view class="xx-content">
                {{item2.val}}
              </view>
            </view>
          </template>
					    
				</view>
				
			</view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { getAdminActivityInfoApi } from '@/addon/htscrm/api';
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';


const detail = ref<IActivityItem>()

onLoad((opt:any)=> {
  console.log(opt);
  
  getDetail(opt.id)
})

async function getDetail(id:any) {
  const res = await getAdminActivityInfoApi(id)
  console.log(res);
  detail.value = res.data
  
}

function xuanzhong(item:any, index:number) {
  const { daan } = item
  return daan.map(item => item.charCodeAt(0) - 'A'.charCodeAt(0)).includes(index)
}
function xuhao(index:number) {
  return String.fromCharCode(65 + index);
}
</script>

<style scoped lang="scss">
.container {
  .header {
		width: 100%;
		height: 550rpx;
    .title {
      height: 100rpx;
      line-height: 100rpx;
      padding: 0 30rpx;
      box-sizing: border-box;
      background-color: #e2e7ff;
      display: flex;
      justify-content: space-between;
      font-size: 30rpx;
      font-weight: 550;
    }
    .audio {
  
      .showBind {
        bottom: 35px;
        height: 40px;
        width: 120px;
        z-index: 999;
        top: auto
      }
    }

    .video {
      width: 100%;
      height: 450rpx;
    }

    .swiper{
		  height: 125rpx;
    }

    .swiper-item {
      display: block;
      height:125rpx;
      line-height: 125rpx;
      text-align: center;

      &__image {
        width: 100%; 
        max-height: 125rpx; 
        background-color: #ffffff;
      }
    }
  }
  
  .content {
    background: #fff;
    padding: 30rpx;
    margin-bottom: 100rpx;
    position: absolute;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 100rpx;
    font-size: 36rpx;
    .item{
      margin-bottom: 30rpx;

      .dati-title{
        /* border-bottom: 2rpx solid #eee; */
        padding-bottom: 20rpx;
        line-height: 1.5;
      }
      .optionbox{
        box-sizing: border-box;
        padding: 20rpx;
      }
      .option-li{
        display: flex;
        align-items: center;
        font-size: 34rpx;
        padding: 20rpx;
        box-sizing: border-box;
            border-radius:10rpx;
            border: 2rpx solid #eee;
            margin-bottom: 20rpx;
      }
      .xx-xuhao{
        height: 52rpx;
        width: 52rpx;
        border: 2rpx solid #eee;
        border-radius: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 20rpx;
        font-size: 36rpx;
      }
      .xx-xuhao.duoxuan{
        border-radius: 10rpx;
      }
      .xx-xuhao.xuanzhong{
        background: #3f51b5;
        color: #fff;
        border-color: #3f51b5;
      }
      .xx-content{
        width: calc(100% - 62rpx - 20rpx);
      }
    }
  }
}
</style>